package book.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import org.junit.Test;

import book.dao.CategoryDao;
import book.dao.impl.CategoryDaoImpl;
import book.entity.Category;
import book.utils.JdbcUtils;

public class TestCategoryDao {
	
	
	private CategoryDao categoryDao = new CategoryDaoImpl();
	
	@Test
	public void getCategory() throws SQLException {
		
		Connection connection = JdbcUtils.getConnection();
		
		String sql ="SELECT category_id as categoryId,category_name as categoryName FROM category WHERE category_id=?";
		
		
		Category category = categoryDao.getCategory(connection, sql, Category.class,1000);
		
		System.out.println(category);
		
	}
	
	
	@Test
	public void getCategoryList() throws SQLException {
		
		
	   Connection connection = JdbcUtils.getConnection();
		
	  String sql=" SELECT category_id as categoryId,category_name as categoryName FROM category";
		
	   List<Category> categoryList = categoryDao.getCategoryList(connection, sql, Category.class);
	   
	   
		
	   for (Category category : categoryList) {
		
		   System.out.println(category);
	}
		
		
	}

}
